//
//  StraDetailTableViewCell.m
//  课余时间
//
//  Created by zgr on 16/4/11.
//  Copyright © 2016年 张大少. All rights reserved.
//

#import "StraDetailTableViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "UIImageView+WebCache.h"
#define IMGHEIGHT (KWIDTH - 16)*[[_model.photoModel[i] image_height] integerValue]/[[_model.photoModel[i] image_width] integerValue]
@implementation StraDetailTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _title = [UILabel new];
        [self.contentView addSubview:_title];

        _title.sd_layout
        .topSpaceToView(self.contentView,5)
        .leftSpaceToView(self.contentView,10)
        .rightSpaceToView(self.contentView,20)
        .autoHeightRatio(0);
        _title.textColor = [UIColor greenColor];
        
        _descText = [UILabel new];
        [self.contentView addSubview:_descText];
       _descText.numberOfLines = 0;
        _descText.sd_layout
        .topSpaceToView(self.title,5)
        .leftSpaceToView(self.contentView,10)
        .rightSpaceToView(self.contentView,20)
        .autoHeightRatio(0);
        
        _backView = [[UIView alloc]init];
        [self.contentView addSubview:_backView];
        _backView.layer.masksToBounds = YES;
       // _backView .backgroundColor = [UIColor redColor];
        // _descText.backgroundColor = [UIColor redColor];
        
       [self setupAutoHeightWithBottomView:_descText bottomMargin:15];
     //   NSLog(@"%@",_model.photoModel);

    }
    return self;
}
//-(void)layoutSubviews
//{
//    //self.height += 100;
//        if (_model.photoModel.count >= 1) {
//            for (int i = 0; i < _model.photoModel.count; i++) {
//    
//                UIImageView *image = [[UIImageView alloc]init];
//              //  [self.contentView addSubview:image];
//    
//                image.sd_layout
//                .leftSpaceToView(self.contentView,6)
//                .topSpaceToView(_descText,2 + KWIDTH * i)
//                .widthIs(KWIDTH - 16)
//                .heightIs(KWIDTH);
//                //  _spaceH = IMGHEIGHT;
//    
//    
//    
//    
//                [image sd_setImageWithURL:[NSURL URLWithString:[_model.photoModel[i] image_url]]];
//                 _img = image;
//    
//                //  [imageArray addObject:image];
//    
//            }
//           // _imageArray = imageArray;
//            
//           // [self setupAutoHeightWithBottomView:_img bottomMargin:5];
//            self.height += KWIDTH *_model.photoModel.count;
//        }
//    
//
//}
-(void)setModel:(SectionsModel *)model
{
    _model = model;
    
    _title.text = model.title;
    _descText.text = model.MyDescription;
   

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
